/**
 *******************************************************************************
 * @FileName  : svc_disc.h
 * @Author    : GaoQiu
 * @CreateDate: 2020-05-18
 * @Copyright : Copyright(C) GaoQiu
 *              All Rights Reserved.
 *******************************************************************************
 *
 * The information contained herein is confidential and proprietary property of
 * GaoQiu and is available under the terms of Commercial License Agreement
 * between GaoQiu and the licensee in separate contract or the terms described
 * here-in.
 *
 * This heading MUST NOT be removed from this file.
 *
 * Licensees are granted free, non-transferable use of the information in this
 * file under Mutual Non-Disclosure Agreement. NO WARRENTY of ANY KIND is provided.
 *
 *******************************************************************************
 */
#ifndef _SVC_DISC_H_
#define _SVC_DISC_H_

#include "utils/defs_types.h"
#include "utils/stimer.h"
#include "utils/mdc.h"
#include "utils/queue.h"
#include "utils/mem_pool.h"

#include "stack/host/att_api.h"

typedef struct Desc_s {
	struct Desc_s   *pNext;
	attDsc_t         dsc;
}Desc_t;

typedef struct Chr_s {
	struct Chr_s    *pNext;
	attChr_t         chr;
	queue_t          desList;
}Chr_t;

typedef struct SvrGrp_s {
	struct SvrGrp_s    *pNext;
	attSvc_t           svc;
	queue_t            chrList;
}Svr_t;

typedef void (*SdpCmplCback_t)(uint16_t connHandle, uint8_t state);

typedef struct SvrDiscCb_s {
	struct SvrDiscCb_s  *pNext;

	uint16_t             connHandle;
	queue_t              svrList;
	SdpCmplCback_t       SdpCmplCback;

	Svr_t               *curSvr;
	Chr_t               *curChr;
	Desc_t              *curDsc;
}SdpCb_t;


void SDP_Init(uint8_t numMaxConn, uint8_t numMaxSvc, uint8_t numMaxChr, uint8_t numMaxDesc);

SdpCb_t* SDP_Find(uint16_t connHandle);
int SDP_Add(uint16_t connHandle);
int SDP_Delete(uint16_t connHandle);

void SDP_DiscAll(uint16_t connHandle, SdpCmplCback_t func);

Svr_t *SDP_FindSvrByHandle(uint16_t connHandle, uint16_t attHandle);
Svr_t *SDP_FindSvrByUuid(uint16_t connHandle, void *uuid, uint32_t uuidLen);
Chr_t *SDP_FindCharByHandle(uint16_t connHandle, uint16_t attHandle);
Chr_t *SDP_FindCharByUUID(uint16_t connHandle, uint8_t *pUuid, uint32_t len);

#endif /* _SVC_DISC_H_ */
